package main

import "fmt"

//for range遍历
//循环数组
func f() {
	var a = [5]int{1, 2, 3, 4, 5}
	for i, v := range a {
		fmt.Printf("i:%v v:%v\n", i, v)
	}
}

//循环字符串
func f1() {
	var s = "胖子大王"
	for i, v := range s {
		fmt.Printf("i:%d v:%c\n", i, v)
	}
}

//循环切片
func f2() {
	var s = []int{1, 2, 3, 4, 5}
	for i, v := range s {
		fmt.Printf("i: %d v:%d\n", i, v)
	}
}

//循环map
func f3() {
	m := make(map[string]string)
	m["name"] = "skye"
	m["age"] = "20"
	m["qq"] = "7405957"
	for i, v := range m {
		fmt.Printf(" %s: %s\n", i, v)
	}
}
func main() {
	//f()
	//f1()
	//f2()
	f3()
}
